<template>
    <div>
        <el-table
        :data="tableData"
        style="width:100%;"
        class="margin_b20 margin_t15"
        >
        <template v-for="(item,index) in columns">
            <el-table-column :fixed="item.fixed" :align="item.align" :key="index" :label="item.label" prop="item.prop">
                <template slot-scope="scope">
                    <ChildTable v-bind="scope.row.children"></ChildTable>
                </template>
            </el-table-column>
        </template>
        <!-- <el-table-column label="客户名称" prop="customeName" min-width="150px"></el-table-column>
        <el-table-column label="客户地址" prop="customAddress" min-width="200px;"></el-table-column>
        <el-table-column
          prop="addReducePercent"
          min-width="130"
          label="增减百分比"
          header-align="center"
          align="right"
        ></el-table-column>
        <el-table-column label="分路计量" header-align="center">
            <el-table-column label="名称" prop="branchName">
                <template slot-scope="scope">
                    <div class="branchWrap">
                    <div v-for="(item,index) in scope.row.branchInfo" :key="index" class="lineHeight28">
                        {{item.amount}}
                    </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column
            label="日期"
            header-align="center"
            align="right"
            min-width="120px"
            prop="lastTimeQty">
                <template slot-scope="scope">
                    <div class="branchWrap">
                    <div v-for="(item,index) in scope.row.branchInfo" :key="index" class="lineHeight28">
                        {{item.lastTimeQty}}
                    </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column
            label="当前时间"
            header-align="center"
            align="right"
            min-width="120px"
            prop="branchThisTime">
                <template slot-scope="scope">
                    <div class="branchWrap">
                    <div v-for="(item,index) in scope.row.branchInfo"
                        :key="index"
                        class="lineHeight28"
                    >{{item.thisTimeQty}}</div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="增减量" header-align="center" align="right" prop="addReduceQty">
                <template slot-scope="scope">
                    <div class="branchWrap">
                        <div
                            v-for="(item,index) in scope.row.branchInfo"
                            :key="index"
                            class="lineHeight28"
                        >{{item.addReduceQty}}</div>
                    </div>
                </template>
            </el-table-column>
      </el-table-column> -->
    </el-table>
    </div>
</template>
<script>
    import ChildTable from "./childTable"
    export default {
        name: "parentTable",
        components:{ChildTable},
        data() {
            return {
                tableData: [
                    {
                        id: 1,
                        customeName: "name-1",
                        customAddress:"北京市石景山区",
                        addReducePercent:'10%',
                        branchName:"ces",
                        branchLastTime:'2019-08-09',
                        branchThisTime:'2019-07-08',
                        branchAddReduceQty:'质量',
                        branchAddReducePercent:'10%',
                        children:[{
                                amount: 100,lastTimeQty:'2019-09-08',addReduceQty:"100",thisTimeQty:'1009',
                                children:[{thisTime:'2019-09-08',lastTime:'2019-09-09'},{thisTime:'2019-09-08',lastTime:'2019-09-09'}]
                            }, { 
                            amount: 200,lastTimeQty:'2019-09-08',addReduceQty:"100",thisTimeQty:'1009',
                                children:[{thisTime:'2019-09-08',lastTime:'2019-09-09'},{thisTime:'2019-09-08',lastTime:'2019-09-09'}]
                        },{ 
                            amount: 300,lastTimeQty:'2019-09-08',addReduceQty:"100",thisTimeQty:'1009',
                            children:[{thisTime:'2019-09-08',lastTime:'2019-09-09'},{thisTime:'2019-09-08',lastTime:'2019-09-09'}]
                        }]
                    },
                    { 
                        id: 2,
                        customeName: "name-2",
                        customAddress:"北京市石景山区",
                        addReducePercent:'10%',
                        branchName:"ces1",
                        branchLastTime:'2019-08-09',
                        branchThisTime:'2019-07-08',
                        branchAddReduceQty:'质量',
                        branchAddReducePercent:'20%',
                        children:[{
                            amount: 100,lastTimeQty:'2019-09-08',addReduceQty:"100",thisTimeQty:'1009',
                                children:[{thisTime:'2019-09-08',lastTime:'2019-09-09'},{thisTime:'2019-09-08',lastTime:'2019-09-09'}]
                            }, { 
                            amount: 200,lastTimeQty:'2019-09-08',addReduceQty:"100",thisTimeQty:'1009',
                            
                                children:[{thisTime:'2019-09-08',lastTime:'2019-09-09'},{thisTime:'2019-09-08',lastTime:'2019-09-09'}]
                        },{ 
                            amount: 300,lastTimeQty:'2019-09-08',addReduceQty:"100",thisTimeQty:'1009',
                            children:[{thisTime:'2019-09-08',lastTime:'2019-09-09'},{thisTime:'2019-09-08',lastTime:'2019-09-09'}]
                        }]
                    },
                    {
                        id: 3,
                        customeName: "name-3",
                        customAddress:"北京市石景山区",
                        addReducePercent:'10%',
                        branchName:"ces3",
                        branchLastTime:'2019-08-09',
                        branchThisTime:'2019-07-08',
                        branchAddReduceQty:'质量',
                        branchAddReducePercent:'30%',
                        children:[{
                            amount: 100,lastTimeQty:'2019-09-08',addReduceQty:"100",thisTimeQty:'1009',
                                children:[{thisTime:'2019-09-08',lastTime:'2019-09-09'},{thisTime:'2019-09-08',lastTime:'2019-09-09'}]
                            }, { 
                            amount: 200,lastTimeQty:'2019-09-08',addReduceQty:"100",thisTimeQty:'1009',
                                children:[{thisTime:'2019-09-08',lastTime:'2019-09-09'},{thisTime:'2019-09-08',lastTime:'2019-09-09'}]
                        },{ 
                            amount: 300,lastTimeQty:'2019-09-08',addReduceQty:"100",thisTimeQty:'1009',
                            children:[{thisTime:'2019-09-08',lastTime:'2019-09-09'},{thisTime:'2019-09-08',lastTime:'2019-09-09'}]
                        }]
                    }
                ]
            }
        },
    }
</script>
